<template>
  <el-dialog :visible.sync="visible" :title="dialogTitle">
    <el-form ref="formRef" :model="formData" :rules="formRules" label-width="100px">
      <el-form-item label="工单标题" prop="title">
        <el-input v-model="formData.title"></el-input>
      </el-form-item>
<!--      <el-form-item label="状态">
        <el-select v-model="formData.status">
          <el-option label="待处理" value="待处理"></el-option>
          <el-option label="处理中" value="处理中"></el-option>
          <el-option label="已完成" value="已完成"></el-option>
        </el-select>
      </el-form-item>-->
      <el-form-item label="分配给" prop="assignedTo">
        <el-input v-model="formData.assignedTo"></el-input>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="closeDialog">取 消</el-button>
      <el-button type="primary" @click="submit">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
export default {
  props: ['visible', 'dialogTitle', 'formData'],
  data() {
    return {
      formRules: {
        title: [
          { required: true, message: '请输入工单标题', trigger: 'blur' }
        ],
        assignedTo: [
          { required: true, message: '请输入分配给', trigger: 'blur' }
        ]
      }
    }
  },
  methods: {
    closeDialog() {
      this.$emit('update:visible', false);
    },
    submit() {
      this.formData.status = '待处理';
      this.$refs.formRef.validate((valid) => {
        if (valid) {
          this.$emit('submit', this.formData);
          this.closeDialog();
        }
      });
    }
  }
};
</script>
